<!doctype html>
<head>
	<meta http-equiv="Content-type" content="text/html; charset=utf-8">
	<title>Change number of columns for full month</title>

	<script src='../../codebase/dhtmlxscheduler.js?v=5.3.10' type="text/javascript" charset="utf-8"></script>
	<script src='../../codebase/ext/dhtmlxscheduler_timeline.js?v=5.3.10' type="text/javascript" charset="utf-8"></script>

	<link rel='stylesheet' type='text/css' href='../../codebase/dhtmlxscheduler_material.css?v=5.3.10'>

	<style type="text/css" >
		html, body{
			margin:0;
			padding:0;
			height:100%;
			overflow:hidden;
		}

		.dhx_scale_bar{
			line-height: 23px;
		}
	</style>

	<script type="text/javascript" charset="utf-8">
		function init() {

			scheduler.locale.labels.timeline_tab = "Month";
			scheduler.locale.labels.section_custom="Section";
			scheduler.config.details_on_create=true;
			scheduler.config.details_on_dblclick=true;

			//===============
			//Configuration
			//===============
			var sections=[
				{key:1, label:"James Smith"},
				{key:2, label:"John Williams"},
				{key:3, label:"David Miller"},
				{key:4, label:"Linda Brown"}
			];

			// timeline config
			scheduler.attachEvent("onTemplatesReady", function(){
				scheduler.xy.scale_height = 50;
			});

			var view_name = "timeline";
			scheduler.createTimelineView({
				name: view_name,
				x_unit: "day",
				x_date: "%D<br><b>%j</b>",
				x_step: 1,
				x_size: 31,
				section_autoheight: false,
				y_unit:   sections,
				y_property: "section_id",
				render:"bar",
				round_position:true,
				dy:60
			});

			scheduler.attachEvent("onBeforeViewChange", function(old_mode,old_date,mode,date){
				var year = date.getFullYear();
				var month= (date.getMonth() + 1);
				var d = new Date(year, month, 0);
				scheduler.matrix[view_name].x_size = d.getDate();//number of days in month;
				return true;
			});
			scheduler.date['add_' + view_name] = function(date, step){
				if(step > 0){
					step = 1;
				}else if(step < 0){
					step = -1;
				}
				return scheduler.date.add(date, step, "month")
			};
			scheduler.date[view_name + '_start'] = scheduler.date.month_start;

			// end timeline config

			//===============
			//Data loading
			//===============
			scheduler.config.lightbox.sections=[
				{name:"description", height:130, map_to:"text", type:"textarea" , focus:true},
				{name:"custom", height:23, type:"select", options:sections, map_to:"section_id" },
				{name:"time", height:72, type:"time", map_to:"auto"}
			];

			scheduler.init('scheduler_here',new Date(2017,5,30),"timeline");
			scheduler.parse([
				{ start_date: "2017-06-01 00:00", end_date: "2017-06-03 00:00", text:"Task A-12458", section_id:1},
				{ start_date: "2017-05-20 00:00", end_date: "2017-06-05 00:00", text:"Task A-89411", section_id:1},
				{ start_date: "2017-06-01 00:00", end_date: "2017-06-03 00:00", text:"Task A-64168", section_id:1},
				{ start_date: "2017-06-04 00:00", end_date: "2017-06-05 00:00", text:"Task A-46598", section_id:1},

				{ start_date: "2017-06-15 00:00", end_date: "2017-06-17 00:00", text:"Task B-48865", section_id:2},
				{ start_date: "2017-06-12 00:00", end_date: "2017-06-13 00:00", text:"Task B-44864", section_id:2},
				{ start_date: "2017-06-18 00:00", end_date: "2017-06-22 00:00", text:"Task B-46558", section_id:2},
				{ start_date: "2017-06-19 00:00", end_date: "2017-06-20 00:00", text:"Task B-45564", section_id:2},

				{ start_date: "2017-06-25 00:00", end_date: "2017-06-26 00:00", text:"Task C-32421", section_id:3},
				{ start_date: "2017-06-14 00:00", end_date: "2017-06-15 00:00", text:"Task C-14244", section_id:3},

				{ start_date: "2017-06-17 00:00", end_date: "2017-06-18 00:00", text:"Task D-52688", section_id:4},
				{ start_date: "2017-06-04 00:00", end_date: "2017-06-05 00:00", text:"Task D-46588", section_id:4},
				{ start_date: "2017-06-29 00:00", end_date: "2017-06-30 00:00", text:"Task D-12458", section_id:4}
			]);
		}
	</script>
</head>
<body onload="init();">
<div id="scheduler_here" class="dhx_cal_container" style='width:100%; height:100%;'>
	<div class="dhx_cal_navline">
		<div class="dhx_cal_prev_button">&nbsp;</div>
		<div class="dhx_cal_next_button">&nbsp;</div>
		<div class="dhx_cal_today_button"></div>
		<div class="dhx_cal_date"></div>
		<div class="dhx_cal_tab" name="timeline_tab" style="right:280px;"></div>
	</div>
	<div class="dhx_cal_header">
	</div>
	<div class="dhx_cal_data">
	</div>
</div>
</body>